//+------------------------------------------------------------------+
//|                                             talasnica_odstup.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window

double nakupiste, prodejiste;
#define PRODEJISTE "prodejiste"
#define NAKUPISTE "nakupiste"

#define TYP_CARY STYLE_SOLID
#define TLOUSTKA_CARY 3
#define BARVA_CARY Silver 

double granica_obchodovanja;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   ObjectDelete(PRODEJISTE);
   ObjectDelete(NAKUPISTE);

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete(PRODEJISTE);
   ObjectDelete(NAKUPISTE);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   granica_obchodovanja = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point;
   nakupiste = NormalizeDouble(Ask + granica_obchodovanja, Digits);
   prodejiste = NormalizeDouble(Bid - granica_obchodovanja, Digits);
  
   nakreslim_caru(PRODEJISTE, prodejiste);
   nakreslim_caru(NAKUPISTE, nakupiste);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

bool nakreslim_caru(string jmeno_cary, double cena) {

   double uspech = false;

   if (ObjectFind(jmeno_cary) < 0) {
      uspech = uspech && (ObjectCreate(jmeno_cary, OBJ_HLINE, 0, 0, cena));
      uspech = uspech && ObjectSet(jmeno_cary, OBJPROP_STYLE, TYP_CARY);
      uspech = uspech && ObjectSet(jmeno_cary, OBJPROP_WIDTH, TLOUSTKA_CARY);
      uspech = uspech && ObjectSet(jmeno_cary, OBJPROP_COLOR, BARVA_CARY);
   }
   
   uspech = uspech && ObjectSet(jmeno_cary, OBJPROP_PRICE1, cena);
   
   return(uspech);
}